//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.tool.custom.progressbar;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
import android.graphics.Paint.Style;
import android.util.AttributeSet;
import android.view.View;

public class CCircleBar extends View {
    private int maxProgress = 100;
    private int progress = 30;
    private int progressStrokeWidth = 4;
    RectF oval = new RectF();
    Paint paint = new Paint();

    public CCircleBar(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        int width = this.getWidth() / 2;
        int height = this.getHeight() / 2;
        int len = this.getWidth() / 4;
        this.paint.setAntiAlias(true);
        this.paint.setColor(-1);
        canvas.drawColor(0);
        this.paint.setStrokeWidth((float)this.progressStrokeWidth);
        this.paint.setStyle(Style.STROKE);
        this.oval.left = (float)(width - len);
        this.oval.top = (float)(height - len);
        this.oval.right = (float)(width + len);
        this.oval.bottom = (float)(height + len);
        this.paint.setColor(-65536);
        canvas.drawArc(this.oval, -90.0F, 360.0F, false, this.paint);
        this.paint.setColor(-16776961);
        canvas.drawArc(this.oval, -90.0F, (float)this.progress / (float)this.maxProgress * 360.0F, false, this.paint);
        this.paint.setStrokeWidth(1.0F);
        String text = this.progress + "%";
        int textHeight = height / 10;
        this.paint.setTextSize((float)textHeight);
        int textWidth = (int)this.paint.measureText(text, 0, text.length());
        this.paint.setStyle(Style.FILL);
        canvas.drawText(text, (float)(this.getWidth() / 2 - textWidth / 2), (float)(this.getHeight() / 2 + textHeight / 2), this.paint);
    }

    public int getMaxProgress() {
        return this.maxProgress;
    }

    public void setMaxProgress(int maxProgress) {
        this.maxProgress = maxProgress;
    }

    public void setProgress(int progress) {
        this.progress = progress;
        this.invalidate();
    }

    public void setProgressNotInUiThread(int progress) {
        this.progress = progress;
        this.postInvalidate();
    }
}
